package com.hontech.bvapp2.ui.parts.heat

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bvapp2.R
import com.hontech.bvapp2.device.cp.Heat
import com.hontech.bvapp2.ui.dialog.runProg
import com.hontech.bvapp2.ui.view.LabelInput
import com.hontech.bvapp2.utils.onClick

class HeatDrawWaterSteamParts (context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_heat_draw_water_steam, this)
        val btnV3 = view.findViewById<Button>(R.id.id_heat_draw_ws_btn_pearl)
        val btnV4 = view.findViewById<Button>(R.id.id_heat_draw_ws_btn_v4)
        val steamStart = view.findViewById<Button>(R.id.id_heat_draw_ws_btn_steam_start)
        val steamStop = view.findViewById<Button>(R.id.id_heat_draw_ws_btn_steam_stop)
        val li = view.findViewById<LabelInput>(R.id.id_heat_draw_ws_li_value)

        btnV3.onClick {
            runProg("煮珍珠", "注水") {
                Heat.drawWater(0, li.textInt())
            }
        }

        btnV4.onClick {
            runProg("泡茶粉", "注水") {
                Heat.drawWater(1, li.textInt())
            }
        }

        steamStart.onClick {
            runProg("", "注入蒸汽") {
                Heat.steamCtrl(0)
            }
        }

        steamStop.onClick {
            runProg("", "注入蒸汽结束") {
                Heat.steamCtrl(1)
            }
        }
    }
}